home *** CD-ROM | disk | FTP | other *** search
- ===========================================================================
- /* fboctree.doc */
-
- Copyright (C) 1993 by Klaus Ehrenfried.
-
- Permission to use, copy, modify, and distribute this software
- is hereby granted, provided that the above copyright notice appears
- in all copies and that the software is available to all free of charge.
- The author disclaims all warranties with regard to this software,
- including all implied warranties of merchant-ability and fitness.
- The code is simply distributed as it is.
-
- ===========================================================================
-
- About FBOCTREE:
-
- The program `fboctree' allows to quantize a 24 bit color image to
- a mapped image. The program uses the Octree algorithm described
- by Michael Gervautz and Werner Purgathofer (Technical University
- Vienna, Austria) in the article "A Simple Method for Color Quantization:
- Octree Quantization" published in Graphic Gems edited by Andrew Glassner
- pp. 287 ff. The program allows to quantize single images and series
- of images as well. A series of images can be quantized so that all
- resulting mapped images have the same color table which is evaluated
- to fit the used colors of the complete series. This is useful when
- the images should later be animated, e.g. with the program `fbm2fli'.
- `fboctree' uses the library of the FBM package to read and write
- the images. Thus is can handle various file formats.
-
- ===========================================================================
-
- Usage:
- fboctree -s [-c<numcolors>] [-d<bits>] [-<type>] < rgb > mapped
- fboctree -a [-c<numcolors>] octree < rgb
- fboctree [-d<bits>] [-<type>] octree < rgb > mapped
-
- "numcolors" is the number of colors used for the Octree quantization.
- This value can range from 9..256, default is 256.
-
- "bits" is the color depth used in the color map of the output image.
- This value can range from 2..8, default is 8.
-
- "type" indicates the format of the output file. Here are few of the
- available formats (for a complete list see the description in the
- FBM package): 'F' = FBM, 'G' = GIF, 'S' = Sun-Raster, 'Z': PCX.
- Default type is FBM.
-
- "octree" is the name of the file which contains the Octree data.
- The Octree data is the information about color distribution in the
- scanned input images. This information determines the color table
- of the mapped output images.
-
- "rgb" is the not mapped input file (e.g. 24 bit FBM image).
-
- "mapped" is the mapped output file (8 bits/pixel; max. 256 colors).
-
- The program can be used in three different modes:
-
- 1) The "-s" option indicates "single" mode. A single 24 bit image
- is converted to a single mapped image.
- Example:
- fboctree -s -G -c128 < abc24.fbm.Z > abc.gif
-
- Reads the 24 bit compressed FBM image "abc24.fbm.Z", quantizes it
- and writes a GIF output image "abc.gif". Due to the given "-c128"
- only 128 colors are used in the color-map of the GIF file.
- Note: The read filter of the FBM package automatically detects that
- the input file is compressed.
-
- 2) The "-a" option indicates "add" mode. A single 24 bit image is
- scanned and it's color information is added to the Octree which
- is read from the file given in the command line. Then the modified
- Octree is written back to the file. Thereby the old information
- in the Octree file is overwritten. If the given Octree file doesn't
- exist a new Octree is generated. Only in this case the "-c" option
- is effective which determines the number of colors used for the
- Octree.
- Example:
- uncompress < abc24.qrt.Z | qrt2fbm | fboctree -a octree.data
-
- "abc24.qrt.Z" is a compressed QRT image generated by the POV or
- DKB ray-tracer. This QRT image is read by "uncompress" and piped
- through the `qrt2fbm' filter from the FBM package which converts
- the image to the FBM format. Then `fboctree' reads the pixel values
- and uses this information to update the Octree which is stored in
- the file "octree.data". Note: The internal read filter of the FBM
- package can't handle the QRT format directly, so that this way with
- the additional external filter `qrt2fbm' is used. The QRT file
- can be kept compressed to save disk space.
-
- 3) Without "-s" and "-a" one gets the simple quantization mode. A single
- 24 bit image is read and the information of the given Octree is
- used to quantize the image to a mapped image.
- Example:
- fboctree -S octree.data < abc24.fbm.Z | compress > abc.rs.Z
-
- The FBM image "abc24.fbm.Z" is quantized and the output is passed
- in SUN raster format via a pipe to the `compress' command which
- finally writes the resulting image to the file "abc8.rs.Z".
- The Octree which is used for the quantization is taken from
- the file "octree.data". The Octree file remains unchanged.
-
- ===========================================================================
-
- Animation (FBOCTREE and FBM2FLI):
-
- Assuming one has 100 QRT images generated by the POV or DKB ray-tracer
- and he or she wants to animate the 100 images in a FLI animation.
- The images are named "nice00.qrt.Z", "nice01.qrt.Z" ... "nice99.qrt.Z".
- All are compressed to save disk space. First step is to generate
- an Octree which represents the color information of all 100 images.
- As name for the Octree file we chose "octree100.data". This file
- doesn't exist at the beginning. Then the Octree is generated with
- the following commands:
-
- uncompress < nice00.qrt.Z | qrt2fbm | fboctree -a octree100.data
- uncompress < nice01.qrt.Z | qrt2fbm | fboctree -a octree100.data
- :
- :
- uncompress < nice99.qrt.Z | qrt2fbm | fboctree -a octree100.data
-
- Now all images are scanned and the Octree (and thereby the color table)
- is ready. The hole information is stored in the file "octree100.data".
- In the second step follows the quantization. To store the mapped
- images we chose the GIF format. The quantization is done with the
- commands:
-
- uncompress < nice00.qrt.Z | qrt2fbm | fboctree -G octree100.data > m00.gif
- uncompress < nice01.qrt.Z | qrt2fbm | fboctree -G octree100.data > m01.gif
- :
- :
- uncompress < nice99.qrt.Z | qrt2fbm | fboctree -G octree100.data > m99.gif
-
- Now we have a series of GIF images with the names "m00.gif" ... "m99.gif".
- To use the `fbm2fli' program we generate a list file by:
-
- ls -1 m*.gif > allgif.list
-
- Thereby we have assumed that no other files in the directory match
- the template "m*.gif". Finally the animation can be done by:
-
- fbm2fli allgif.list anim100.fli
-
- The complete way to get a FLI animation from QRT images seems to be
- rather complicated especially in comparison to the MS DOS program DTA.
- This is definitely true, but the complicated way offers on the
- other hand more flexibility. We can handle more file formats and the
- `fboctree' program is more consistent with the other utilities of the
- FBM package like `fbquant'.
-
- ===========================================================================
-
- FBOCTREE vs FBQUANT:
-
- The program `fbquant' is the quantization program of the FBM package.
- In principle it does the same what `fboctree' does, but it uses a
- different algorithm, namely a variant of Heckbert's adaptive partitioning
- method. Additionally Floyd-Steinberg dithering is used to reduce color
- banding (Note: The automatic dithering of `fbquant' can be avoided by
- specifying the "-n" option, although this possibility is not mentioned
- in the man page for `fbquant'). Basically the algorithm used by `fbquant'
- gives better results than the Octree method, but is has some disadvantages,
- if a FLI animation with the resulting mapped images is planned.
- The dithering improves the quality of the mapped images significantly
- but the resulting images are less suitable for the use in FLI animations.
- If dithered images are used, the resulting FLI file is much bigger than in
- the case where the images are not dithered. This results from the special
- compression method used in the FLI standard.
- If the size of the resulting FLI file or the animation speed is a critical
- point, the quantization method with `fboctree' as described above has
- to be preferred.
-
- ===========================================================================
-
- Installation:
-
- Like the program `fbm2fli' also `fboctree' requires the library of the
- FBM package from Michael Mauldin (mlm@nl.cs.cmu.edu).
- This package is available via FTP as
-
- "nl.cs.cmu.edu:/usr/mlm/ftp/fbm.tar.Z".
-
- Probably some changes in the makefile are required to indicate
- where the FBM stuff is located on your machine and which compiler
- is used.
-
- -- Klaus Ehrenfried (klaus@spock.es.go.dlr.de)
-
-